<?php
    // 连接数据库
    if(!($db=new SQLite3('czz.db', '0666')))
    {
        echo "<h2>数据库连接错误！</h2>";
        die();
    }
?>
<!DOCTYPE html>
<html lang="zh" class="no-js">
  <head>
    <meta charset="utf-8">
    <title>业余无线电台操作证书考试在线学习系统 - 黑龙江火腿网</title>
  </head>
  <body>
  <table align=center width=640px><tr><td>
      <?php
          // 页码
          if(@$_REQUEST['page']){
            $page = $_REQUEST['page'];
          } else
          {
            $page = 0;
          }
          // 等级选择
          if(@$_REQUEST['czz_class']=="a")
          {
            $czz_dj = "czz_a";
          }
          if(@$_REQUEST['czz_class']=="b")
          {
            $czz_dj = "czz_b";
          }
          if(@$_REQUEST['czz_class']=="c")
          {
            $czz_dj = "czz_c";
          }
          // 显示数量
          $num = $_REQUEST['czz_xssl'];
          $pagej = $num*$page;
          // 显示方式与显示内容
          if(@$_REQUEST['czz_xsfs']=="2")
          {
            if($num == "all"){
              $result=$db->query("SELECT $czz_dj.czz_i,czz.* FROM $czz_dj,czz WHERE $czz_dj.czz_i = czz.czz_i ORDER BY $czz_dj.czz_i;");
            } else {
              $result=$db->query("SELECT $czz_dj.czz_i,czz.* FROM $czz_dj,czz WHERE $czz_dj.czz_i = czz.czz_i ORDER BY $czz_dj.czz_i LIMIT  $num OFFSET $pagej;");
            }
            
            while($row=$result->fetchArray(SQLITE3_ASSOC))
            {
              echo "<p><b>问:".$row['czz_q']."</b><br /><br />";
              echo "答:".$row['czz_a']."<br />";
              $pic = $row['czz_i'];
              if(file_exists("pic/$pic.jpg"))
              {
                echo "图:<img src=\"pic/".$row['czz_i'].".jpg\" /></p>";
              }
            }
          }
          if(@$_REQUEST['czz_xsfs']=="1")
          {
            if($num == "all"){
              $result=$db->query("SELECT $czz_dj.czz_i,czz.* FROM $czz_dj,czz WHERE $czz_dj.czz_i = czz.czz_i ORDER BY $czz_dj.czz_i;");
            } else {
              $result=$db->query("SELECT $czz_dj.czz_i,czz.* FROM $czz_dj,czz WHERE $czz_dj.czz_i = czz.czz_i ORDER BY $czz_dj.czz_i LIMIT  $page , $num;");
            }
            
            while($row=$result->fetchArray(SQLITE3_ASSOC))
            {
              echo "<p><b>问:".$row['czz_q']."</b><br /><br />";
              echo "正确:<font color=red>".$row['czz_a']."<br /></font>";
              echo "错误:".$row['czz_b']."<br />";
              echo "错误:".$row['czz_c']."<br />";
              echo "错误:".$row['czz_d']."<br />";
              $pic = $row['czz_i'];
              if(file_exists("pic/$pic.jpg"))
              {
                echo "<img src=\"pic/".$row['czz_i'].".jpg\" /></p>";
              }
            }
          }

        ?>
      <p>
      <?php 
       if($num != "all")
        {
          if($page!=0)
          {
          $pageu = $page-1;
          echo "<a href=\"./show.php?czz_class=".$_REQUEST['czz_class']."&czz_xsfs=".$_REQUEST['czz_xsfs']."&page=".$pageu."&czz_xssl=".$num."\">上一题</a>&nbsp;&nbsp;&nbsp;";
          }
          $paged = $page+1;
          echo "<a href=\"./show.php?czz_class=".$_REQUEST['czz_class']."&czz_xsfs=".$_REQUEST['czz_xsfs']."&page=".$paged."&czz_xssl=".$num."\">下一题</a>&nbsp;&nbsp;&nbsp;";
        }
      ?>
      <a href="index.html">返回</a>
      </p>
</td></tr></tebal>
 

    
  </body>
</html>
<?php
    // 关闭数据库
    $db->close();
?>
